#ifndef WMCALLBACK_H
#define WMCALLBACK_H

#include "common.h"

class WMCallback
{
public:
	typedef LRESULT (CALLBACK* TAGWNDPROC)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LPVOID tag);

	WMCallback(HINSTANCE hInstance, LPVOID tag = 0);
	~WMCallback();
	void OnWmCallback(WNDPROC proc);
	void OnTaggedWmCallback(TAGWNDPROC proc);
	HWND GetHWnd();
private:
	HWND hWnd;
	WNDPROC wndProc;
	TAGWNDPROC tagWndProc;
	LPVOID tag;

	static map<HWND, WMCallback*> instances;
	static WMCallback* tmpInstance;

	static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
};

#endif